package com.lagou.ipersistence.executor.result;

import com.lagou.ipersistence.session.ResultContext;

/**
 * @author Yan Jiahong
 * Created on 2020/11/23
 */
public class DefaultResultContext<T> implements ResultContext<T> {
    private T resultObject;
    private int resultCount;
    private boolean stopped;
    
    public DefaultResultContext() {
        resultObject = null;
        resultCount = 0;
        stopped = false;
    }
    
    @Override
    public T getResultObject() {
        return resultObject;
    }
    
    @Override
    public int getResultCount() {
        return resultCount;
    }
    
    @Override
    public boolean isStopped() {
        return stopped;
    }
    
    @Override
    public void stop() {
        this.stopped  =true;
    }
    
    public void nextResultObject(T resultObject) {
        resultCount++;
        this.resultObject = resultObject;
    }
}
